﻿@using System.Text;
@using Blazor.Diagrams.Extensions;
@{
    var borderColor = Node.Selected ? $"outline-{Node.Color}-darker" : $"outline-{Node.Color}";
    var extraClasses = new StringBuilder().Append($"bg-{Node.Color}").AppendIf(" rounded-full", Node.Round);
}

<div class="drop-shadow-lg @borderColor flex items-center justify-center font-bold @extraClasses" style="width: @(Node.Round ? 80 : 120)px; height: @(Node.Round ? 80 : 60)px;">
    @Node.Title

    @foreach (var port in Node.Ports)
    {
        var classes = new StringBuilder("absolute -translate-y-1/2 ")
            .Append(extraClasses)
            .AppendIf(" top-1/2 -right-3", port.Alignment == PortAlignment.Right)
            .AppendIf(" top-1/2 -left-3", port.Alignment == PortAlignment.Left);

        <PortRenderer Port="port" Class="@classes.ToString()" Style="width: 10px; height: 10px;" />
    }
</div>

@code {

    [Parameter]
    public ColoredNodeModel Node { get; set; } = null!;

} 